from dealexcel import Excel

try:
    oldfile = input("拖入excel文件:")

    readexcel = Excel(oldfile)

    writhexcel = Excel("output.xlsx","w")

    read = readexcel.get_col_values(0,0)
    print(read)
    writhexcel.write_values((0,0) ,["问题","答案1","答案2","答案3"],"h",0)
    n = 1
    print(len(read))
    for i in range(0,len(read),4):
        try:
            w = [read[i],read[i+1],read[i+2],read[i+3]]
            writhexcel.write_values((n, 0), w, "h", 0)
            n += 1
            print(w)
        except Exception:
            num = len(read)-(4*(n-1))
            print(num)
            lastrow = []
            for j in range(num):
                print(4*n+j)
                print(read[(4*(n-1))+j])
                lastrow.append(read[(4*(n-1))+j])
            writhexcel.write_values((n, 0), lastrow, "h", 0)
            print(lastrow)
    writhexcel.save_file()
except Exception as e:
    print(e)
a = input("回车退出")
